<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>v-bind小作业</title>
  <style>
    #app ul {
      width: 80px;
      list-style: none;
    }

    .red {
      color: red;
    }

    .click {
      padding-top: 15px;
      cursor: pointer;
      transition: 0.3s;
    }

    .click:hover {
      transform: scale(1.2, 1.2);
    }
  </style>
</head>

<body>

  <div id="app">
    <ul>
      <!-- v-for 语法，用于遍历循环 -->
      <li class="click" v-for="(item, index) in movies" :class="{red: index == counter}" @click="counter=index">
        {{ (index + 1) + ' ' + item }}</li>
    </ul>
  </div>

  <script src="../../js/vue.js"></script>
  <script>
    const app = new Vue({
      el: '#app',
      data: {
        counter: 0,
        red: "red",
        movies: [
          '星际穿越',
          '大话西游',
          '盗梦空间',
          '二十不惑',
          '三十而已'
        ]
      }
    })
  </script>
</body>

</html>